{extend name="platform/base" /}
{block name="resources"/}
<style>
.col-md-2 {
    line-height: 35px;
}
</style>
{/block}
{block name="main"}
<section class="panel panel-default">
	<header class="panel-heading text-right bg-light">
		<ul class="nav nav-tabs pull-left">
			<li class="active"><a href="#base" data-toggle="tab">店铺信息</a></li>
		</ul>
		<span class="hidden-sm">添加店铺</span>
	</header>
	<div class="panel-body">
		<div class="tab-content">
			<div class="tab-pane fade active in" id="base">
					<div class="panel-body">
						<form class="form-horizontal">
						
							<div class="form-group">
								<label class="col-sm-2 control-label">会员账号</label>
								<div class="col-md-2">
									<input type="text" class="form-control" id="user_account"
										value="" placeholder="请输入会员账号">
								</div>
							</div>
							<div class="line line-dashed line-lg pull-in"></div>
							
							<div class="form-group">
								<label class="col-sm-2 control-label">会员密码</label>
								<div class="col-md-2">
									<input type="password" class="form-control" id="user_pwd"
										value="" placeholder="请输入会员密码">
								</div>
							</div>
							<div class="line line-dashed line-lg pull-in"></div>
							
							<div class="form-group">
								<label class="col-sm-2 control-label">店铺名称</label>
								<div class="col-md-2">
									<input type="text" class="form-control" id="shop_name"
										value="" placeholder="请输入店铺名称">
								</div>
							</div>
							
							<div class="line line-dashed line-lg pull-in"></div>
							<div class="form-group">
								<label class="col-sm-2 control-label">所属分类</label>
								<div class="col-md-4">
									<select id="shop_group_id" name="account"
										class="form-control m-b"> 
										{foreach name="group_list" item="vg"}
											<option value="{$vg['shop_group_id']}">{$vg['group_name']}</option>
										{/foreach}
									</select>
								</div>
							</div>
							
							<div class="line line-dashed line-lg pull-in"></div>
							<div class="form-group">
								<label class="col-sm-2 control-label">所属等级</label>
								<div class="col-md-4">
									<select id="shop_type" name="account" class="form-control m-b">
										{foreach name="type_list" item="vt"}
											<option value="{$vt['instance_typeid']}">{$vt['type_name']}</option>
										{/foreach}
									</select>
								</div>
							</div>
							
							
							<div class="form-group">
								<div class="col-sm-4 col-sm-offset-2">
									<a href="javascript:void(0);" onclick="addShopAjax()"
										class="btn btn-primary">保存</a>
								</div>
							</div>
						</form>
					</div>
			</div>

		</div>
	</div>
	
</section>

<script type="text/javascript"> 


	//添加店铺
	function addShopAjax() {
		
		var user_account = $("#user_account").val();
		var user_pwd = $("#user_pwd").val();
		var shop_name = $("#shop_name").val();
		var shop_group_id = $("#shop_group_id").val();
		var shop_type = $("#shop_type").val();
		
		if(user_account == ''){
			showMessage('error', '会员账号不能为空！');
		}
		if(user_pwd == ''){
			showMessage('error', '会员密码不能为空！');
		}
		if(shop_name == ''){
			showMessage('error', '店铺名称不能为空！');
		}
		
		$.ajax({
			type : "post",
			url : "PLATFORM_MAIN/shop/addPlatformShop",
			data : {
				'shop_name' : shop_name,
				'shop_group_id' : shop_group_id,
				'shop_type' : shop_type,
				'user_account' : user_account,
				'user_pwd' : user_pwd
			},
			async : true,
			success : function(data) {
				if (data["code"] > 0) {
					showMessage('success', "添加成功",'PLATFORM_MAIN/Shop/shoplist');
				} else {
					showMessage('error', data['message']);
				}
			}
		});
	}
</script>
{/block}
